﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using DevExpress.XtraEditors;

namespace TMIS
{
    public partial class frmStudent : XtraForm
    {
        private BLL.Student bll = new BLL.Student();
        public frmStudent()
        {
            InitializeComponent();
            this.FillComponent();
        }
        private void FillComponent()
        {
            comDepartment.Properties.Items.AddRange(bll.GetDepartment());
            this.studentTableAdapter.Fill(this.reportDS.Student);
        }
        private void frmStudent_Load(object sender, EventArgs e)
        {
        }

        private void comGrade_SelectedValueChanged(object sender, EventArgs e)
        {
            comClass.Properties.Items.Clear();
            comClass.Properties.Items.AddRange(bll.GetClass(comGrade.Text));
        }

        private void comProfession_SelectedValueChanged(object sender, EventArgs e)
        {
            comGrade.Properties.Items.Clear();
            comGrade.Properties.Items.AddRange(bll.GetGrade(comProfession.Text));
        }

        private void comDepartment_SelectedValueChanged(object sender, EventArgs e)
        {
            comProfession.Properties.Items.Clear();
            comProfession.Properties.Items.AddRange(bll.GetProfession(comDepartment.Text));
        }

        private void btnSearch_Click(object sender, EventArgs e)
        {
            this.studentTableAdapter.FillByClassID(this.reportDS.Student, bll.GetClassID(comClass.Text));
            this.dataGridView.Refresh();
        }

        private void btnApproval_Click(object sender, EventArgs e)
        {
            Guid guid = new Guid(this.dataGridView.SelectedCells[0].OwningRow.Cells["ID"].Value.ToString());
            foreach (var f in this.MdiChildren)
            {
                f.Close();
            }
            frmApproval frm = new frmApproval(guid);
            frm.Show();
        }

        private void btnOpenReport_Click(object sender, EventArgs e)
        {
            Guid guid = new Guid(this.dataGridView.SelectedCells[0].OwningRow.Cells["ID"].Value.ToString());
            foreach (var f in this.MdiChildren)
            {
                f.Close();
            }
            frmOpenReport frm = new frmOpenReport(guid);
            frm.Show();
        }

        private void btnInstructionOpinion_Click(object sender, EventArgs e)
        {
            Guid guid = new Guid(this.dataGridView.SelectedCells[0].OwningRow.Cells["ID"].Value.ToString());
            foreach (var f in this.MdiChildren)
            {
                f.Close();
            }
            frmInstructionOpinion frm = new frmInstructionOpinion(guid);
            frm.Show();
        }

        private void btnReviewOpinion_Click(object sender, EventArgs e)
        {
            Guid guid = new Guid(this.dataGridView.SelectedCells[0].OwningRow.Cells["ID"].Value.ToString());
            foreach (var f in this.MdiChildren)
            {
                f.Close();
            }
            frmReviewOpinion frm = new frmReviewOpinion(guid);
            frm.Show();
        }

        private void btnReply_Click(object sender, EventArgs e)
        {
            Guid guid = new Guid(this.dataGridView.SelectedCells[0].OwningRow.Cells["ID"].Value.ToString());
            foreach (var f in this.MdiChildren)
            {
                f.Close();
            }
            frmReply frm = new frmReply(guid);
            frm.Show();
        }

        private void btnIdentify_Click(object sender, EventArgs e)
        {
            Guid guid = new Guid(this.dataGridView.SelectedCells[0].OwningRow.Cells["ID"].Value.ToString());
            foreach (var f in this.MdiChildren)
            {
                f.Close();
            }
            frmIdentify frm = new frmIdentify(guid);
            frm.Show();
        }

        private void btnRecommand_Click(object sender, EventArgs e)
        {
            Guid guid = new Guid(this.dataGridView.SelectedCells[0].OwningRow.Cells["ID"].Value.ToString());
            foreach (var f in this.MdiChildren)
            {
                f.Close();
            }
            frmRecommend frm = new frmRecommend(guid);
            frm.Show();
        }

        private void btnDelStudent_Click(object sender, EventArgs e)
        {

        }
    }
}
